<template>
	<div  class="pages">
		<mescroll-uni @init="mescrollInit" :top="top" @down="downCallback" :bottom="bottom"  :up="upOption"
			@up="upCallback" >
		<view class="items" v-for="(items,index) in dadaList" :key="index" @click="$next('/pages/home/LicensingCom/LicensingWeb',{url:items.abstracts})">
			<view class="itemsLeft" @click.stop="$imgShow(items.cover)">
				<image :src="items.cover" mode="" style="width: 100%;height: 100%;"  ></image>
			</view>
			<view class="itemsRight">
				<view class="itemsRightTxt">
					<!-- Insurance Licence Exam instruction -->
					
					<span>{{hotLength(items.title,35) || ''}}</span>
					
				</view>
				<view class="itemsRightDate"  v-html="items.content">
					<!-- Some description about the document. -->
				</view>

			</view>
		</view>
		</mescroll-uni>
	</div>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				newUrl:0,//0为新接口1为老接口
				searchKey: '',
				upOption: {
					noMoreSize: 10, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认10,
				},
				top: "26rpx",
				bottom:"60rpx",
				dadaList: [],
				pager: {
					currentPage: 1,
					maxResultCount: 10
				},
			}
		},
		watch:{
			searchKey:{
				handler() {
					this.getList()
				}
			}
			
		},
		onShow() {
			// this.getList()
		},
		methods: {
			upCallback(page) {
				this.pager.currentPage = page.num; //在第几页
				this.pager.maxResultCount = page.size; //展示多少条数据
				this.getList()
			},
			downCallback(page) { // 下拉刷新
				this.mescroll.resetUpScroll();
			},
			timestamp(val) {
				 // 将时间戳字符串转换为 Date 对象
				      const dateObject = new Date(val);
				      // 获取新闻时间戳（以毫秒为单位）
				      const timestamp = dateObject.getTime();
					  // 获取现在时间戳
					  const currentTimestamp = Date.now();
					  let resuiltDate = currentTimestamp - timestamp
					  let date = new Date(resuiltDate)
					  let year = date.getFullYear()
					  let month = date.getMonth() + 1
					  let day = date.getDate()
					  let h = date.getHours()
					  let text = `${h}`
					  console.log(resuiltDate,'现在时间戳');
					  return text
			},
			// 文字超出打点
			hotLength(val,len){
				if ( val.length > len) {
					return `${val.substring(0,len)}...`
				} else {
					return val
				}
			},
			// 获取数据
			async getList() {
				uni.showLoading({
					title: this.$t('Laoding'),
				})
				const res = await this.$get(`/biz/app/licensingOrNewsPage`, {
					current: this.pager.currentPage,
					size: this.pager.maxResultCount,
					searchKey: this.searchKey,
					type: 1,
				},this.newUrl)
				console.log(res, 'Insurance Licence Exam instruction');
				if (res.data.data.total >= 0) {
					if (this.pager.currentPage == 1) {
						this.dadaList = []
					}
					this.dadaList = this.dadaList.concat(res.data.data.records)
					this.dadaList.reverse()
				}
				this.mescroll.endBySize(res.data.data.records.length, res.data.data.total)
			},
		}
	}
</script>


<style>
	.pages {
		width: 100%;
		height: 100vh;
		overflow-y: auto;
		padding: 0 26rpx 60rpx;
		box-sizing: border-box;
		background-color: #F0F0F0;
	}
	.serachBox {
		width: 100%;
		height: 64rpx;
		margin-top: 26rpx;
	}
	.items {
		/* display: flex;
		justify-content: flex-start; */
		
		width: 700rpx;
		/* height: 658rpx; */
		background-color: #fff;
		border-radius: 16rpx;
		/* margin-top: 26rpx; */
		margin: 26rpx auto 0;
		padding: 26rpx;
		box-sizing: border-box;
	}
	
	.itemsLeft {
		width: 100%;
		height: 340rpx;
		background: rgba(39, 53, 98, 0.37);
		margin-right: 26rpx;
	}
	.itemsRightTxt {
	font-family: Montserrat;
	font-size: 32rpx;
	font-weight: 700;
	letter-spacing: 0.20000000298023224px;
	text-align: left;
	margin-top: 15rpx;
	}
	.itemsRightDate {
	font-family: Montserrat;
	font-size: 16px;
	font-weight: 400;
	/* line-height: 15px; */
	/* height: 300rpx; */
	letter-spacing: 0.20000000298023224px;
	text-align: left;
	margin-top: 15rpx;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	}
</style>